/**   
 * @Title: FootballLatestMatchInfoCoummunicater.java 
 * @Package: com.esun.rabbit2.communicaters.lotteryinfo 
 * @Description: (最新足球比赛结果) 
 * @Author: Billy qigs@500wan.com   
 * @Date: 2011-8-16 上午11:37:28  
 * Copyright (C) 2011 Shenzhen E-sun Sky Net Technology Co.,ltd.
 */
package com.esun.rabbit2.communicaters.lotteryinfo;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;

import javax.xml.parsers.ParserConfigurationException;

import org.apache.http.client.ClientProtocolException;
import org.xml.sax.SAXException;

import com.esun.config.BussinessCode;
import com.esun.config.Config;
import com.esun.config.Key;
import com.esun.model.LotteryInfoFootballInfo;
import com.esun.network.ServerCommunicater;
import com.esun.util.log.EDebug;

/**
 * @ClassName: FootballLatestMatchInfoCoummunicater
 * @Description: (最近足球比赛结果)
 * @Author: Billy qigs@500wan.com
 * @Date: 2011-8-16 上午11:37:28
 */
public class FootballLatestMatchInfoCoummunicater extends ServerCommunicater {

	private String msgServer;

	private boolean isSucceed = false;

	public String getMsgServer() {
		return msgServer;
	}

	public void setMsgServer(String msgServer) {
		this.msgServer = msgServer;
	}

	/**
	 * @throws SAXException
	 * @throws ParserConfigurationException
	 * @throws IOException
	 * @throws ClientProtocolException
	 * @Title: isGetCurrentLotInfo
	 * @Description: (获取竞彩足球最新一场比赛信息接口 业务编号10009)
	 * @param @return isSucceed
	 * @return boolean 返回类型
	 * @throws
	 */
	public boolean isGetFootballLotteryInfo() throws ClientProtocolException, IOException, ParserConfigurationException, SAXException {
		ArrayList<HashMap<String, String>> list = new ArrayList<HashMap<String, String>>();
		list.add(mapItem(Config.PASER_MID, BussinessCode.MID_FOOTBALL_LATEST_LOTTERY_INFO));
		list.add(mapItem(Config.PASER_CK, Config.NULLMARK));

		super.getServerResponse(list, true);
		if (super.getState() == 100) {
			isSucceed = true;
			if (super.getListResult().size() == 0) {
				EDebug.o("list 为空");
				isSucceed = false;
			} else {
				EDebug.o("list 不为空");
			}
		} else {
			isSucceed = false;
		}
		setMsgServer(super.getServerMsg());
		EDebug.o(this, super.getErrorMSG());

		return isSucceed;
	}

	public LotteryInfoFootballInfo getLatestFootballInfo() {
		LotteryInfoFootballInfo footballInfo = new LotteryInfoFootballInfo();

		footballInfo.setHomeTeam(super.getListResult().get(0).get(Key.KEY_HOMESXNAME));
		EDebug.o(this, "football home team = " + super.getListResult().get(0).get(Key.KEY_HOMESXNAME));
		footballInfo.setMatchDate(super.getListResult().get(0).get(Key.KEY_MATCHNUMDATE));
		footballInfo.setVisitingTeam(super.getListResult().get(0).get(Key.KEY_AWAYSXNAME));
		footballInfo.setScore(super.getListResult().get(0).get(Key.KEY_SCORE));
		footballInfo.setRangQiu(super.getListResult().get(0).get(Key.KEY_RANGQIU));

		return footballInfo;
	}

	private HashMap<String, String> mapItem(String name, String value) {
		HashMap<String, String> map = new HashMap<String, String>();
		map.put(name, value);
		return map;
	}
}
